# Maintainer: Loïc Bartoletti <loic.bartoletti@oslandia.com>

_realname=pysfcgal
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=1.4.1
pkgrel=2
pkgdesc='Python SFCGAL binding (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('spdx:MIT')
url='https://gitlab.com/Oslandia/pysfcgal'
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-sfcgal
    ${MINGW_PACKAGE_PREFIX}-python-cffi
)
makedepends=(${MINGW_PACKAGE_PREFIX}-python-setuptools
    ${MINGW_PACKAGE_PREFIX}-python-wheel
    ${MINGW_PACKAGE_PREFIX}-python-cffi
    ${MINGW_PACKAGE_PREFIX}-cc)
source=(https://gitlab.com/Oslandia/pysfcgal/-/archive/v${pkgver}/pysfcgal-v${pkgver}.tar.gz)
sha256sums=('a519cdb3a89dea11f92bee91f284cecd56dc88e4b0eda4f37d1c7268c0289980')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-v${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
